package com.example.demo.service;

import com.example.demo.pojo.Case;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.demo.dao.CaseDao;

import java.util.List;


@Service("caseServiceImpl")
public class CaseServiceImpl implements CaseService {
    @Autowired
    private CaseDao caseDao;

    @Override
    public List<Case> showAll() {
        List<Case> allCase = caseDao.selectCase();
        int counter = allCase.size();
        System.out.println(counter);
        return allCase;
    }

    @Override
    public List<Case> searchCase(int id) {
        List<Case> result = caseDao.selectCaseById(id);
        int counter = result.size();
        System.out.println(counter);
        return result;
    }

    @Override
    public int addCase(Case newcase) {
        return caseDao.insertCase(newcase);
    }
}
